import os
import pandas as pd
import cv2
# import numpy as np
from matplotlib import pyplot as plt
from skimage.feature import (graycomatrix,graycoprops)
# import skimage.io
import skimage.filters
from skimage.morphology import disk
# from skimage import exposure


# 返回截取的污泥部分
def wFeatureCal(path1,flag
                ):
  x = []
  v1 = []
  v2 = []
  v3 = []
  v4 = []
  v5 = []
  v6 = []
  v7 = []
  v8 = []
  data = pd.read_excel(path1)
  for i in range(0, len(data['ASM']) - 1):
    x.append(data['xaixs'][i])

    v4.append(data['dissimilarity'][i])
    v5.append(data['homogeneity'][i])
    v6.append(data['ASM'][i])

    v8.append(data['correlation'][i])

  font1 = {'family': 'Times New Roman', 'weight': 'normal', 'size': 20}

  # 二维中的保存内容是纹理特征dissimilarity  homogeneity  ASM  energy  correlation  contrast
  AAO1 = [[],[],[],[],[],[]]
  AAOYuan = [[],[],[],[],[],[]]
  YangHua1 = [[],[],[],[],[],[]]
  YangHua = [[],[],[],[],[],[]]

  font1 = {'family': 'Times New Roman', 'weight': 'normal', 'size': 20}

  if flag == 0:
    N = 2
    M = 2
    # 形成NxM大小的画布

    plt.figure(figsize=(32, 16))
    plt.figure(1)
    plt.subplot(N, M, 1)
    # plt.figure(figsize=(16, 8))
    plt.title('homogeneity Trendency', fontsize=10, pad=15)
    # plt.xlabel('picture num', font1)
    # plt.ylabel('average area', font1)
    plt.grid(True)
    plt.plot(x, v5)
    plt.xticks([])
    plt.yticks([])

    plt.subplot(N, M, 2)
    # plt.figure(figsize=(16, 8))
    plt.title('ASM Trendency', fontsize=10, pad=15)
    # plt.xlabel('picture num', font1)
    # plt.ylabel('average count', font1)
    plt.grid(True)
    plt.plot(x, v6)
    plt.xticks([])
    plt.yticks([])

    plt.subplot(N, M, 3)
    # plt.figure(figsize=(16, 8))
    plt.title('contrast Trendency', fontsize=10, pad=15)
    # plt.xlabel('picture num', font1)
    # plt.ylabel('average count', font1)
    plt.grid(True)
    plt.plot(x, v4)
    plt.xticks([])
    plt.yticks([])

    plt.subplot(N, M, 4)
    # plt.figure(figsize=(16, 8))
    plt.title('correlation Trendency', fontsize=10, pad=15)
    # plt.xlabel('picture num', font1)
    # plt.ylabel('average count', font1)
    plt.grid(True)
    plt.plot(x, v8)
    plt.xticks([])
    plt.yticks([])
    plt.show()
  elif flag==1:

    # plt.plot(xaixs,AAOYuan[0],linewidth=6)
    # plt.plot(xaixs,YangHua1[0],linewidth=6)
    # plt.plot(xaixs,YangHua[0],linewidth=6)



    legendName = ['AAO-1','AAOyuan','YangHua1','YangHua']
    font1 = {'family': 'Times New Roman','weight': 'normal','size': 35}
    font2 = {'family': 'Times New Roman','weight': 'normal','size': 14}
    plt.figure(figsize=(30, 15))
    plt.tick_params(labelsize=25)
    plt.title('homogeneity Trendency',fontsize=35, pad=40)
    #plt.legend(legendName,prop=font1)
    plt.xlabel('time/min', font1)
    plt.ylabel('homogeneity', font1)
    plt.grid(True)
    #plt.figure(figsize=(30, 15))
    plt.plot(x, v5, linewidth=6)
    plt.show()
  elif flag==2:


    # AAO1 = [[],[],[],[],[],[]]
    # AAOYuan = [[],[],[],[],[],[]]
    # YangHua = [[],[],[],[],[],[]]
    # YangHua1 = [[],[],[],[],[],[]]



    # plt.plot(xaixs,AAOYuan[1],linewidth=6)
    # plt.plot(xaixs,YangHua1[1],linewidth=6)
    # plt.plot(xaixs,YangHua[1],linewidth=6)



    legendName = ['AAO-1','AAOyuan','YangHua1','YangHua']
    font1 = {'family': 'Times New Roman','weight': 'normal','size': 35}
    font2 = {'family': 'Times New Roman','weight': 'normal','size': 14}
    plt.figure(figsize=(30, 15))
    plt.tick_params(labelsize=25)
    plt.title('ASM Trendency',fontsize=35, pad=40)
    #plt.legend(legendName,prop=font1)
    plt.xlabel('time/min', font1)
    plt.ylabel('ASM', font1)
    plt.grid(True)

    plt.plot(x, v6, linewidth=6)
    plt.show()


  elif flag==3:
    # AAO1 = [[],[],[],[],[],[]]
    # AAOYuan = [[],[],[],[],[],[]]
    # YangHua = [[],[],[],[],[],[]]
    # YangHua1 = [[],[],[],[],[],[]]



    # plt.plot(xaixs,AAOYuan[2],linewidth=6)
    # plt.plot(xaixs,YangHua1[2],linewidth=6)
    # plt.plot(xaixs,YangHua[2],linewidth=6)



    legendName = ['AAO-1','AAOyuan','YangHua1','YangHua']
    font1 = {'family': 'Times New Roman','weight': 'normal','size': 35}
    font2 = {'family': 'Times New Roman','weight': 'normal','size': 14}
    plt.figure(figsize=(30, 15))
    plt.tick_params(labelsize=25)
    plt.title('contrast Trendency',fontsize=35, pad=40)
    #plt.legend(legendName,prop=font1)
    plt.xlabel('time/min', font1)
    plt.ylabel('contrast', font1)
    plt.grid(True)

    plt.plot(x, v4, linewidth=6)
    plt.show()


    # AAO1 = [[],[],[],[],[],[]]
    # AAOYuan = [[],[],[],[],[],[]]
    # YangHua = [[],[],[],[],[],[]]
    # YangHua1 = [[],[],[],[],[],[]]


  elif flag==4:

    # plt.plot(xaixs,AAOYuan[4],linewidth=6)
    # plt.plot(xaixs,YangHua1[4],linewidth=6)
    # plt.plot(xaixs,YangHua[4],linewidth=6)



    legendName = ['AAO-1','AAOyuan','YangHua1','YangHua']
    font1 = {'family': 'Times New Roman','weight': 'normal','size': 35}
    font2 = {'family': 'Times New Roman','weight': 'normal','size': 14}
    plt.figure(figsize=(30, 15))
    plt.tick_params(labelsize=25)
    plt.title('correlation Trendency',fontsize=35, pad=40)
    #plt.legend(legendName,prop=font1)
    plt.xlabel('time/min', font1)
    plt.ylabel('correlation', font1)
    plt.grid(True)

    plt.plot(x, v8, linewidth=6)
    plt.show()


